home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #3 / Amiga Plus CD - 2002 - No. 03.iso / AmiSoft / Util / Misc / Reportplus.lha / reportplus / source / f2.c < prev    next >
C/C++ Source or Header  |  2003-02-14  |  42KB  |  1,252 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3. #include <clib/exec_protos.h>
  4. #include <intuition/intuition.h>
  5. #include <clib/intuition_protos.h>
  6. #include <libraries/gadtools.h>
  7. #include <clib/gadtools_protos.h>
  8. #include <graphics/gfx.h>
  9. #include <clib/graphics_protos.h>
  10.  
  11. #include <clib/alib_protos.h>
  12. #include <ctype.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include "rp.h"
  16.  
  17. #define ALL_REACTION_CLASSES
  18. #define ALL_REACTION_MACROS
  19. #include <reaction/reaction.h>
  20. #include <gadgets/texteditor.h>
  21. #include <clib/texteditor_protos.h>
  22. #include <pragmas/texteditor_pragmas.h>
  23.  
  24. #define MAINTYPES   15
  25. #define CATEGORIES 343
  26. struct
  27. {   ULONG start, end;
  28. } offsets[MAINTYPES + 1] =
  29. {   16,  26, // biz
  30.     27,  47, // comm
  31.     48,  73, // demo
  32.     74,  90, // dev
  33.     91,  97, // disk
  34.     98, 105, // docs
  35.    106, 120, // game
  36.    121, 132, // gfx
  37.    133, 135, // hard
  38.    136, 140, // info
  39.    141, 150, // misc
  40.    151, 263, // mods
  41.    264, 267, // mus
  42.    268, 309, // pix
  43.    310, 320, // text
  44.    321, 343  // util
  45. };
  46.  
  47. AGLOBAL struct AminetStruct aminet;
  48.  
  49. // from rp.c
  50. IMPORT ABOOL                fillwindows;
  51. IMPORT SBYTE                page;
  52. IMPORT TEXT                 IOBuffer[LONGESTFIELD + 1],
  53.                             aslresult[PATHNAMEFIELD + 1],
  54.                             string[LONGESTFIELD + 1];
  55. IMPORT ULONG                offset;
  56. IMPORT struct SharedStruct  shared;
  57. IMPORT struct Window*       MainWindowPtr;
  58. IMPORT struct Library*      TextEditorBase;
  59. IMPORT Object*              WinObject[FUNCTIONS + 1]; // note that WindowObject is a reserved macro
  60. IMPORT struct Menu*         MenuPtr;
  61. IMPORT struct Screen*       ScreenPtr;
  62. IMPORT struct TextAttr      Topaz8;
  63.  
  64. MODULE void updateaminetgadgets(void);
  65. MODULE void updatesubtype(void);
  66.  
  67. MODULE ABOOL          MainTypeNodes     = FALSE,
  68.                       SubTypeNodes      = FALSE;
  69. MODULE struct List    MainTypeList,
  70.                       SubTypeList;
  71.  
  72. MODULE struct Gadget *aminet_gadgets[GIDS_2 + 1];
  73.  
  74. MODULE struct
  75. {   STRPTR name;
  76.     STRPTR desc;
  77. } category[CATEGORIES + 1] =
  78. { // all (0)
  79. "biz",   "Business software",
  80. "comm",  "Communications",
  81. "demo",  "Gfx and sound demos",
  82. "dev",   "Development software",
  83. "disk",  "Disk/Harddisk tools",
  84. "docs",  "Text documents",
  85. "game",  "Games",
  86. "gfx",   "Graphics",
  87. "hard",  "Hardware",
  88. "info",  "General FTP information",
  89. "misc",  "Miscellaneous",
  90. "mods",  "Music modules",
  91. "mus",   "Musical software",
  92. "pix",   "Pictures",
  93. "text",  "Text related",
  94. "util",  "Utilities",
  95. // biz (16)
  96. "cloan", "Cloanto software & support",
  97. "dbase", "Data base software",
  98. "demo",  "Demo versions of commercial software",
  99. "dkg",   "DarkAge software & support",
  100. "dopus", "Directory Opus files",
  101. "haage", "Haage & Partner software & support",
  102. "misc",  "Misc business type soft",
  103. "patch", "Commercial software patches",
  104. "p5",    "phase5 software & support",
  105. "swood", "Softwood products",
  106. "titan", "Titan Computer software",
  107. // comm (27)
  108. "ambos", "AmBoS (BBS) related",
  109. "amiex", "Ami-Express BBS related",
  110. "bbs",   "BBS programs",
  111. "cnet",  "CNET BBS related",
  112. "dlg",   "DLG BBS related",
  113. "fido",  "FIDO software",
  114. "irc",   "Internet Relay Chat software",
  115. "mail",  "Mailing soft",
  116. "maxs",  "MaxsBBS related",
  117. "mebbs", "MEBBSNet BBS related",
  118. "misc",  "Misc communications",
  119. "mmgr",  "MailManager related",
  120. "net",   "Networking",
  121. "news",  "Newsreaders",
  122. "tcp",   "AmiTCP networking",
  123. "term",  "Terminal programs",
  124. "thor",  "Thor mail/news system",
  125. "ums",   "Universal Message System",
  126. "uucp",  "UUCP software",
  127. "www",   "World Wide Web software",
  128. "xeno",  "Xenolink BBS related",
  129. // demo (48)
  130. "40k",   "40K intros",
  131. "aga",   "Demos requiring AGA chipset",
  132. "bse",   "Belgian Scene Event files",
  133. "disk",  "Demos on diskettes",
  134. "ecs",   "Demos for the ECS chip set",
  135. "euro",  "Euro demos in file form",
  136. "file",  "Single file demos",
  137. "funet", "From the Funet collection",
  138. "intro", "Intros",
  139. "mag",   "Demo coder magazines",
  140. "mega",  "Euro demos requiring floppies",
  141. "slide", "Image oriented demos",
  142. "sound", "Sound oriented demos",
  143. "sp96",  "Saturne Party 96 demos",
  144. "ta95",  "Demos from The Assembly 95",
  145. "ta96",  "Demos from The Assembly 96",
  146. "ta97",  "Demos from The Assembly 97",
  147. "tg93",  "The Gathering 1993 demos",
  148. "tg95",  "The Gathering 1995 demos",
  149. "tg96",  "The Gathering 1996 demos",
  150. "tg97",  "The Gathering 1997 demos",
  151. "tp92",  "Demos from The Party 92",
  152. "tp94",  "Demos from The Party 94",
  153. "tp95",  "Demos from The Party 95",
  154. "tp96",  "Demos from The Party 96",
  155. "track", "Trackmos",
  156. // dev (74)
  157. "amos",  "AMOS BASIC compiler",
  158. "asm",   "Assembly language related",
  159. "basic", "BASIC language related",
  160. "c",     "C language related",
  161. "cross", "Cross development",
  162. "debug", "Debugging software",
  163. "e",     "E language related",
  164. "gcc",   "GNU C compiler",
  165. "gg",    "Geek Gadgets GNU software",
  166. "gui",   "GUI builders",
  167. "lang",  "Various languages",
  168. "m2",    "Modula-2 related",
  169. "misc",  "Misc development software",
  170. "moni",  "Monitors/disassemblers",
  171. "mui",   "MagicUserInterface related",
  172. "obero", "Oberon related software",
  173. "src",   "Tutorial sources",
  174. // disk (92)
  175. "bakup", "Backup software",
  176. "cache", "Disk caching",
  177. "cdrom", "CD-ROM related software",
  178. "misc",  "Various disk related tools",
  179. "moni",  "Disk monitors",
  180. "optim", "Disk optimizers",
  181. "salv",  "Disk recovery software",
  182. // docs (99)
  183. "anno",  "Announcement documents",
  184. "etext", "Project Gutenberg books",
  185. "help",  "Help on various issues",
  186. "hyper", "Hypertext documents",
  187. "lists", "Lists and tables",
  188. "mags",  "Magazines",
  189. "misc",  "Various documents",
  190. "rview", "Amiga product reviews",
  191. // game (107)
  192. "2play", "2 and more player games",
  193. "actio", "Action games",
  194. "board", "Board games",
  195. "data",  "Data files for games",
  196. "demo",  "Demos of commercial games",
  197. "gag",   "Gag programs",
  198. "hint",  "Game hint documents",
  199. "jump",  "Jump-n-run games",
  200. "misc",  "Miscellaneous games",
  201. "patch", "Patches for games",
  202. "role",  "Role, adventure games",
  203. "shoot", "Shoot-em-up games",
  204. "text",  "Text based adventures",
  205. "think", "Mind games",
  206. "wb",    "Workbench games",
  207. // gfx  (122)
  208. "3d",    "3D graphics software",
  209. "3dobj", "3D objects",
  210. "aga",   "AGA chip set software",
  211. "board", "Custom gfx board software",
  212. "conv",  "Gfx conversion tools",
  213. "edit",  "Paint programs",
  214. "fract", "Fractals and Mandelbrots",
  215. "ifx",   "ImageFX related files",
  216. "misc",  "Misc graphics software",
  217. "pbm",   "Pbm+ gfx conversion",
  218. "show",  "Image/anim displayers",
  219. "x11",   "Amiga X-Windows",
  220. // hard (134)
  221. "drivr", "Drivers for hardware",
  222. "hack",  "Selfmade hardware",
  223. "misc",  "Misc hardware related files",
  224. // info (137)
  225. "adt",   "Machine readable filelists",
  226. "index", "Various Aminet index files",
  227. "sites", "Info on other FTP sites",
  228. "start", "Beginner information",
  229. "stats", "Statistics about this site",
  230. // misc (142)
  231. "amag",  "German Amiga Mag PD",
  232. "antiq", "Nostalgic stuff",
  233. "edu",   "Educational software",
  234. "emu",   "Emulations",
  235. "imdb",  "Internet Movie Database",
  236. "kids",  "Children's software",
  237. "math",  "Mathematics",
  238. "misc",  "Uncategorizable",
  239. "sci",   "Scientific software",
  240. "unix",  "Amiga related UNIX software",
  241. // mods (152)
  242. "32bit", "MP3s by 32bit choonz",
  243. "4mat",  "Mods by 4mat",
  244. "8voic", "8-voiced songs",
  245. "airon", "Mods by Airon",
  246. "alpma", "Mods by Johan Alpmar",
  247. "atmos", "Atmospheric music",
  248. "aweso", "Mods by Dr Awesome",
  249. "bhead", "Mods by Basehead",
  250. "bladr", "Mods by Black Dragon",
  251. "blk",   "Mods by Black Shadow",
  252. "blkha", "Mods by Blakkhar",
  253. "boing", "Boing collection",
  254. "boray", "Mods by Boray",
  255. "casef", "Mods by Case and Filippetto",
  256. "cato",  "Mods by Don Cato",
  257. "cels",  "Mods by Celsius",
  258. "chart", "Module hits",
  259. "chip",  "Mods without samples",
  260. "chrom", "Mods by Chromag",
  261. "chryl", "Mods by Chrylian",
  262. "clawz", "Mods by Clawz",
  263. "cloud", "Mods by Cloud",
  264. "crash", "Mods by Crash Noise Division",
  265. "crn",   "Mods by Corrosion",
  266. "ctp",   "Mods by Counterpoint",
  267. "cutc",  "Mods by Cutcreator",
  268. "darde", "Mods by Fredius Darde",
  269. "dean",  "Mods by Dean",
  270. "delor", "Mods by Delorean",
  271. "demo",  "Demo style music",
  272. "dizzy", "Mods by Dizzy",
  273. "dlusn", "Mods by D.Lusion",
  274. "doh",   "Mods by Doh",
  275. "dremr", "Mods by Dreamer",
  276. "dsx",   "Mods by DSX",
  277. "elbie", "Mods by Elbie",
  278. "emax",  "Mods by Emax",
  279. "ephnx", "Mods by Euphonix",
  280. "essen", "Mods by Essential Sound", // new for 5.63
  281. "evrim", "Mods by Evrimsson",
  282. "exprt", "Mods by Expert",
  283. "facet", "Mods by Facet",
  284. "fby",   "Mods by Fabio Barzagli",
  285. "fermx", "Mods by Fermix",
  286. "fox2",  "Mods by TheFoxII",
  287. "funet", "Funet collection",
  288. "funk",  "Funky/jazzy mods",
  289. "hardc", "Hardcore techno",
  290. "hje",   "Mods by H.J. Ehrentraud",
  291. "huezo", "Mods by Huezo",
  292. "house", "House modules",
  293. "hw",    "Mods by Hillware",
  294. "inst",  "Instruments for modules",
  295. "instr", "Instrumental music",
  296. "jogei", "Mods by Jogeir Liljedahl",
  297. "jorma", "Mods by Da Jormas (techno)",
  298. "jungl", "Jungle/Breakbeat mods",
  299. "k4k",   "Mods by k4k",
  300. "kaa",   "Mods by Redd Kaa",
  301. "lead",  "Mods by Lead",
  302. "mark",  "Mods by Mark Salud",
  303. "maxym", "Mods by Maxym",
  304. "med",   "MED modules",
  305. "melod", "Melodic modules",
  306. "melom", "Mods by MeloManiac",
  307. "midi",  "Music in MIDI format",
  308. "misc",  "Miscellaneous songs",
  309. "mnc",   "Mods by Meanace",
  310. "mpg",   "Music in MPEG audio format",
  311. "mryo",  "Mods by Mr. Yo",
  312. "mvp",   "Mods by MoPlayaz",
  313. "ncase", "Mods by Nutcase",
  314. "neuro", "Neurodancer's modules",
  315. "nork",  "Mods by Nork",
  316. "ooze",  "Mods by Ooze",
  317. "otis",  "Mods by Otis",
  318. "panik", "Mods by Panik",
  319. "pdy",   "Mods by Prodigy",
  320. "pete",  "Mods by Pirate Pete",
  321. "piano", "Piano mods",
  322. "pop",   "Pop music",
  323. "pro",   "Protracker songs",
  324. "przk",  "Mods by Parsec",
  325. "punn",  "Mods by Punnik",
  326. "purg",  "Mods by Purgatory",
  327. "racoo", "Mods by Racoon",
  328. "rated", "Misc rated modules",
  329. "rebel", "Mods by Rebel Riffs",
  330. "rock",  "Rock'n'Roll",
  331. "roz",   "Mods by Roz",
  332. "s3m",   "Multichannel s3m mods",
  333. "sbc",   "Modules by Substance",
  334. "sets",  "Module collections",
  335. "sidew", "Mods by Sidewinder",
  336. "slc",   "Mods by Slice",
  337. "slow",  "Slow, melodic modules",
  338. "smg",   "Modes by esemgy",
  339. "smpl",  "Sound samples",
  340. "sonor", "Mods by Sonority",
  341. "spark", "Mods by P.D. Spark",
  342. "stame", "Mods by Stamen",
  343. "synth", "Synthesizer modules",
  344. "techn", "Techno music",
  345. "toady", "Mods by Olivier Gonneau",
  346. "tranc", "Trance techno mods",
  347. "tp96",  "Mods from The Party 1996",
  348. "uns",   "Mods by UnIsOn",
  349. "vdo",   "Mods by Voodoo Audio Group", // new for 5.63
  350. "voice", "Music with voices",
  351. "voy",   "Mods by Voyager",
  352. "wmr",   "Mods reviewed by WMR",
  353. "xceed", "Mods by X-Ceed (ex Snoopy)",
  354. "xm",    "Multichannel xm mods",
  355. // mus (261)
  356. "edit",  "Composing software",
  357. "midi",  "MIDI software",
  358. "misc",  "Miscellaneous",
  359. "play",  "Sound players",
  360. // pix (265)
  361. "3dani", "3D animations",
  362. "addic", "Pictures by 3DAddict",
  363. "anim",  "Animations",
  364. "art",   "Hand drawn imagery",
  365. "astro", "Astronomy pictures",
  366. "back",  "Workbench backdrop pictures",
  367. "bill",  "Bill Graham traces",
  368. "boot",  "Boot pictures",
  369. "clip",  "Clip art",
  370. "eps",   "Structured EPS images",
  371. "eric",  "Eric Schwartz anims",
  372. "fauna", "Animals",
  373. "fract", "Fractals",
  374. "gicon", "GlowIcons",
  375. "glenn", "Traces by Glenn J. Schworak",
  376. "guard", "Guardians traces",
  377. "heiko", "Traces by Heiko Popp",
  378. "henz",  "Traces by Patrick Henz",
  379. "icon",  "Workbench icons",
  380. "illu",  "Illustrations",
  381. "imagi", "Imagine traces",
  382. "irc",   "The people on IRC",
  383. "jake",  "The Ragtime Gallery",
  384. "jason", "Jason Brown illustration",
  385. "map",   "Images of maps",
  386. "mark",  "Traces by Markus Kuhnen",
  387. "misc",  "Miscellaneous images",
  388. "mpg",   "MPEG animations",
  389. "mwb",   "MagicWB icons",
  390. "nevil", "Pics by Neville Rolle",
  391. "nicon", "NewIcons",
  392. "park",  "Maps of US national parks",
  393. "real3", "Real3D traces",
  394. "sport", "Sports pictures",
  395. "textu", "Textures",
  396. "tp96",  "Pics from The Party 1996",
  397. "trace", "Raytraced pictures",
  398. "unrl",  "Animations by Unreal",
  399. "vehic", "Vehicle images",
  400. "views", "Scenery, countries",
  401. "wb",    "Example WB screens",
  402. "wfm",   "Artwork of William F. Maddock",
  403. // text (305)
  404. "bfont", "Bitmap font collection",
  405. "dtp",   "Desk top publishing",
  406. "edit",  "Editors",
  407. "font",  "Fonts of all formats and related too", // ..."ls"
  408. "hyper", "Hypertext tools",
  409. "ifont", "Intellifont collection",
  410. "misc",  "Misc text software",
  411. "pfont", "Postscript font collection",
  412. "print", "Printing tools",
  413. "show",  "Text displayers",
  414. "tex",   "TeX formatting package",
  415. // util (316)
  416. "app",   "AppIcons, AppWindows",
  417. "arc",   "Archivers",
  418. "batch", "Script software",
  419. "blank", "Screen blankers",
  420. "boot",  "Startup sequence software",
  421. "cdity", "Commodity type software",
  422. "cli",   "Command line interface",
  423. "conv",  "File conversion",
  424. "crypt", "Encryption tools",
  425. "dir",   "Directory utilities",
  426. "dtype", "Datatypes for OS 3.x",
  427. "gnu",   "GNU utilities",
  428. "libs",  "Libraries",
  429. "misc",  "Miscellaneous",
  430. "moni",  "System monitors",
  431. "mouse", "Mouse accelerators",
  432. "pack",  "Packers",
  433. "rexx",  "ARexx tools",
  434. "shell", "Shells",
  435. "sys",   "Common file replacements",
  436. "time",  "Clocks and timing",
  437. "virus", "Virus checkers",
  438. "wb",    "Workbench utilities"
  439. };
  440.  
  441. AGLOBAL void aminet1(void)
  442. {   struct Hook Hook2Struct;
  443.  
  444.     if ((!(aminet.uploader[0])) && readin("S:Report.sender"))
  445.     {   /* # Refer: <last>,<first> (<company> ,phone <phone>)<LF>
  446.            # Path: <email><LF>
  447.            # ReferID: <developer><LF> */
  448.  
  449.         offset = 0;
  450.         parse("# Refer: ");
  451.         parse(",");
  452.         parse(" (");
  453.         parse(" ,phone ");
  454.         parse(")\n# Path: ");
  455.         parse("\n# ReferID: ");
  456.         strcpy(aminet.uploader, string);
  457.     }
  458.  
  459.     InitHook(&Hook2Struct, Hook2Func, NULL);
  460.  
  461.     /* Create the window object. */
  462.     lockscreen();
  463.  
  464. if (!(WinObject[2] =
  465. NewObject
  466. (   WINDOW_GetClass(),                    NULL,
  467.     WA_PubScreen,                         ScreenPtr,
  468.     WA_ScreenTitle,                       "Report+",
  469.     WA_Title,                             "Report+: Aminet Readme Editor",
  470.     WA_Activate,                          TRUE,
  471.     WA_DepthGadget,                       TRUE,
  472.     WA_DragBar,                           TRUE,
  473.     WA_CloseGadget,                       TRUE,
  474.     WA_SizeGadget,                        TRUE,
  475.     WA_IDCMP,                             IDCMP_RAWKEY,
  476.     WINDOW_IDCMPHook,                     &Hook2Struct,
  477.     WINDOW_IDCMPHookBits,                 IDCMP_RAWKEY,
  478.     WINDOW_MenuStrip,                     MenuPtr,
  479.     WINDOW_Position,                      WPOS_CENTERSCREEN,
  480.     WINDOW_ParentGroup,                   aminet_gadgets[GID_2_LY1] =
  481.     NewObject
  482.     (   LAYOUT_GetClass(),                NULL,
  483.         LAYOUT_Orientation,               LAYOUT_ORIENT_VERT,
  484.         LAYOUT_SpaceOuter,                TRUE,
  485.         LAYOUT_DeferLayout,               TRUE,
  486.         LAYOUT_AddChild,
  487.         NewObject
  488.         (   LAYOUT_GetClass(),            NULL,
  489.             LAYOUT_Orientation,           LAYOUT_ORIENT_HORIZ,
  490.             LAYOUT_DeferLayout,           TRUE,
  491.             LAYOUT_BevelStyle,            BVS_NONE,
  492.             LAYOUT_AddChild,
  493.             NewObject
  494.             (   LAYOUT_GetClass(),        NULL,
  495.                 LAYOUT_Orientation,       LAYOUT_ORIENT_VERT,
  496.                 LAYOUT_VertAlignment,     LALIGN_CENTER,
  497.                 LAYOUT_BevelStyle,        BVS_NONE,
  498.                 LAYOUT_AddChild,
  499.                 NewObject
  500.                 (   LAYOUT_GetClass(),    NULL,
  501.                     LAYOUT_Orientation,   LAYOUT_ORIENT_HORIZ,
  502.                     LAYOUT_HorizAlignment,LALIGN_RIGHT,
  503.                     LAYOUT_BevelStyle,    BVS_NONE,
  504.                     LAYOUT_AddImage,
  505.                     NewObject
  506.                     (   LABEL_GetClass(),     NULL,
  507.                         LABEL_Text,           "_Short:",
  508.                         LABEL_Justification,  LJ_RIGHT,
  509.                     TAG_END),
  510.                 TAG_END),
  511.                 LAYOUT_AddChild,
  512.                 NewObject
  513.                 (   LAYOUT_GetClass(),        NULL,
  514.                     LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  515.                     LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  516.                     LAYOUT_BevelStyle,        BVS_NONE,
  517.                     LAYOUT_AddImage,
  518.                     NewObject
  519.                     (   LABEL_GetClass(),     NULL,
  520.                         LABEL_Text,           "_Uploader:",
  521.                         LABEL_Justification,  LJ_RIGHT,
  522.                     TAG_END),
  523.                 TAG_END),
  524.                 LAYOUT_AddChild,
  525.                 NewObject
  526.                 (   LAYOUT_GetClass(),        NULL,
  527.                     LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  528.                     LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  529.                     LAYOUT_BevelStyle,        BVS_NONE,
  530.                     LAYOUT_AddImage,
  531.                     NewObject
  532.                     (   LABEL_GetClass(),     NULL,
  533.                         LABEL_Text,           "_Author:",
  534.                         LABEL_Justification,  LJ_RIGHT,
  535.                     TAG_END),
  536.                 TAG_END),
  537.                 LAYOUT_AddChild,
  538.                 NewObject
  539.                 (   LAYOUT_GetClass(),        NULL,
  540.                     LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  541.                     LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  542.                     LAYOUT_BevelStyle,        BVS_NONE,
  543.                     LAYOUT_AddImage,
  544.                     NewObject
  545.                     (   LABEL_GetClass(),     NULL,
  546.                         LABEL_Text,           "_Replaces:",
  547.                         LABEL_Justification,  LJ_RIGHT,
  548.                     TAG_END),
  549.                 TAG_END),
  550.                 LAYOUT_AddChild,
  551.                 NewObject
  552.                 (   LAYOUT_GetClass(),        NULL,
  553.                     LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  554.                     LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  555.                     LAYOUT_BevelStyle,        BVS_NONE,
  556.                     LAYOUT_AddImage,
  557.                     NewObject
  558.                     (   LABEL_GetClass(),     NULL,
  559.                         LABEL_Text,           "R_equires:",
  560.                         LABEL_Justification,  LJ_RIGHT,
  561.                     TAG_END),
  562.                 TAG_END),
  563.                 LAYOUT_AddChild,
  564.                 NewObject
  565.                 (   LAYOUT_GetClass(),        NULL,
  566.                     LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  567.                     LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  568.                     LAYOUT_BevelStyle,        BVS_NONE,
  569.                     LAYOUT_AddImage,
  570.                     NewObject
  571.                     (   LABEL_GetClass(),     NULL,
  572.                         LABEL_Text,           "_Version:",
  573.                         LABEL_Justification,  LJ_RIGHT,
  574.                     TAG_END),
  575.                 TAG_END),
  576.                 LAYOUT_AddChild,
  577.                 NewObject
  578.                 (   LAYOUT_GetClass(),        NULL,
  579.                     LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  580.                     LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  581.                     LAYOUT_BevelStyle,        BVS_NONE,
  582.                     LAYOUT_AddImage,
  583.                     NewObject
  584.                     (   LABEL_GetClass(),     NULL,
  585.                         LABEL_Text,           "_Distribution:",
  586.                         LABEL_Justification,  LJ_RIGHT,
  587.                     TAG_END),
  588.                 TAG_END),
  589.             TAG_END),
  590.             CHILD_WeightedWidth,      0,
  591.             LAYOUT_AddChild,
  592.             NewObject
  593.             (   LAYOUT_GetClass(),    NULL,
  594.                 LAYOUT_Orientation,   LAYOUT_ORIENT_VERT,
  595.                 LAYOUT_VertAlignment, LALIGN_CENTER,
  596.                 LAYOUT_HorizAlignment,LALIGN_CENTER,
  597.                 LAYOUT_BevelStyle,    BVS_NONE,
  598.                 LAYOUT_AddChild,      aminet_gadgets[GID_2_ST1] =
  599.                 NewObject
  600.                 (   STRING_GetClass(),    NULL,
  601.                     GA_ID,                GID_2_ST1,
  602.                     GA_TabCycle,          TRUE,
  603.                     STRINGA_TextVal,      aminet.amishort,
  604.                     STRINGA_MinVisible,   20,
  605.                     STRINGA_MaxChars,     40,
  606.                 TAG_END),
  607.                 LAYOUT_AddChild,          aminet_gadgets[GID_2_ST2] =
  608.                 NewObject
  609.                 (   STRING_GetClass(),    NULL,
  610.                     GA_ID,                GID_2_ST2,
  611.                     GA_TabCycle,          TRUE,
  612.                     STRINGA_TextVal,      aminet.uploader,
  613.                     STRINGA_MinVisible,   20,
  614.                     STRINGA_MaxChars,     40,
  615.                 TAG_END),
  616.                 LAYOUT_AddChild,          aminet_gadgets[GID_2_ST3] =
  617.                 NewObject
  618.                 (   STRING_GetClass(),    NULL,
  619.                     GA_ID,                GID_2_ST3,
  620.                     GA_TabCycle,          TRUE,
  621.                     STRINGA_TextVal,      aminet.author,
  622.                     STRINGA_MinVisible,   20,
  623.                     STRINGA_MaxChars,     40,
  624.                 TAG_END),
  625.                 LAYOUT_AddChild,          aminet_gadgets[GID_2_ST4] =
  626.                 NewObject
  627.                 (   STRING_GetClass(),    NULL,
  628.                     GA_ID,                GID_2_ST4,
  629.                     GA_TabCycle,          TRUE,
  630.                     STRINGA_TextVal,      aminet.version,
  631.                     STRINGA_MinVisible,   20,
  632.                     STRINGA_MaxChars,     40,
  633.                 TAG_END),
  634.                 LAYOUT_AddChild,          aminet_gadgets[GID_2_ST5] =
  635.                 NewObject
  636.                 (   STRING_GetClass(),    NULL,
  637.                     GA_ID,                GID_2_ST5,
  638.                     GA_TabCycle,          TRUE,
  639.                     STRINGA_TextVal,      aminet.replaces,
  640.                     STRINGA_MinVisible,   20,
  641.                     STRINGA_MaxChars,     40,
  642.                 TAG_END),
  643.                 LAYOUT_AddChild,          aminet_gadgets[GID_2_ST6] =
  644.                 NewObject
  645.                 (   STRING_GetClass(),    NULL,
  646.                     GA_ID,                GID_2_ST6,
  647.                     GA_TabCycle,          TRUE,
  648.                     STRINGA_TextVal,      aminet.requires,
  649.                     STRINGA_MinVisible,   20,
  650.                     STRINGA_MaxChars,     40,
  651.                 TAG_END),
  652.                 LAYOUT_AddChild,          aminet_gadgets[GID_2_ST7] =
  653.                 NewObject
  654.                 (   STRING_GetClass(),    NULL,
  655.                     GA_ID,                GID_2_ST7,
  656.                     GA_TabCycle,          TRUE,
  657.                     STRINGA_TextVal,      aminet.distribution,
  658.                     STRINGA_MinVisible,   20,
  659.                     STRINGA_MaxChars,     40,
  660.                 TAG_END),
  661.             TAG_END),
  662.         TAG_END),
  663.         CHILD_WeightedHeight,         0,
  664.         LAYOUT_AddChild,
  665.         NewObject
  666.         (   LAYOUT_GetClass(),        NULL,
  667.             LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  668.             LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  669.             LAYOUT_BevelStyle,        BVS_NONE,
  670.             LAYOUT_AddImage,
  671.             NewObject
  672.             (   LABEL_GetClass(),     NULL,
  673.                 LABEL_Text,           "_Long description:",
  674.                 LABEL_Justification,  LJ_CENTER,
  675.             TAG_END),
  676.         TAG_END),
  677.         CHILD_WeightedHeight,         0,
  678.         LAYOUT_AddChild,              aminet_gadgets[GID_2_TE1] =
  679.         NewObject
  680.         (   TEXTEDITOR_GetClass(),    NULL,
  681.             GA_ID,                    GID_2_TE1,
  682.             GA_TabCycle,              TRUE,
  683.             GA_RelVerify,             TRUE,
  684.             GA_TEXTEDITOR_ExportWrap, 75,
  685.         TAG_END),
  686.         CHILD_WeightedHeight,         50,
  687.         CHILD_MinHeight,              92,
  688.         LAYOUT_AddChild,
  689.         NewObject
  690.         (   LAYOUT_GetClass(),        NULL,
  691.             LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  692.             LAYOUT_HorizAlignment,    LALIGN_RIGHT,
  693.             LAYOUT_BevelStyle,        BVS_NONE,
  694.             LAYOUT_AddImage,
  695.             NewObject
  696.             (   LABEL_GetClass(),     NULL,
  697.                 LABEL_Text,           "Directory:",
  698.                 LABEL_Justification,  LJ_CENTER,
  699.             TAG_END),
  700.             CHILD_WeightedWidth,      50,
  701.             LAYOUT_AddImage,
  702.             NewObject
  703.             (   LABEL_GetClass(),     NULL,
  704.                 LABEL_Text,           "Subdirectory:",
  705.                 LABEL_Justification,  LJ_CENTER,
  706.             TAG_END),
  707.             CHILD_WeightedWidth,      50,
  708.         TAG_END),
  709.         CHILD_WeightedHeight,         0,
  710.         LAYOUT_AddChild,
  711.         NewObject
  712.         (   LAYOUT_GetClass(),        NULL,
  713.             LAYOUT_Orientation,       LAYOUT_ORIENT_HORIZ,
  714.             LAYOUT_HorizAlignment,    LALIGN_CENTER,
  715.             LAYOUT_BevelStyle,        BVS_NONE,
  716.             LAYOUT_AddChild,          aminet_gadgets[GID_2_LB1] =
  717.             NewObject
  718.             (   LISTBROWSER_GetClass(),NULL,
  719.                 GA_ID,                 GID_2_LB1,
  720.                 GA_RelVerify,          TRUE,
  721.                 GA_TextAttr,           &Topaz8,
  722.                 LISTBROWSER_Labels,    (ULONG) &MainTypeList,
  723.                 LISTBROWSER_MinVisible,6,
  724.                 LISTBROWSER_ShowSelected,TRUE,
  725.             TAG_END),
  726.             LAYOUT_AddChild,           aminet_gadgets[GID_2_LB2] =
  727.             NewObject
  728.             (   LISTBROWSER_GetClass(),NULL,
  729.                 GA_ID,                 GID_2_LB2,
  730.                 GA_RelVerify,          TRUE,
  731.                 GA_TextAttr,           &Topaz8,
  732.                 LISTBROWSER_Labels,    (ULONG) &SubTypeList,
  733.                 LISTBROWSER_MinVisible,6,
  734.                 LISTBROWSER_ShowSelected,TRUE,
  735.             TAG_END),
  736.         TAG_END),
  737.         CHILD_WeightedHeight,          50,
  738.     TAG_END),
  739. TAG_END)))
  740. {   rq("Can't create ReAction gadgets!");
  741. }
  742. unlockscreen();
  743. openwindow();
  744.  
  745.     SetGadgetAttrs
  746.     (   aminet_gadgets[GID_2_TE1],    MainWindowPtr, NULL,
  747.         GA_TEXTEDITOR_Contents, aminet.textfield
  748.     ); // long description
  749.     OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_NEW,    NOSUB));
  750.     OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_OPEN,   NOSUB));
  751.     OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVE,   NOSUB));
  752.     OnMenu(MainWindowPtr, FULLMENUNUM(MN_PROJECT, IN_SAVEAS, NOSUB));
  753.  
  754.     updatesubtype();
  755.     ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST1]);
  756.     loop();
  757.     readaminetgadgets();
  758.     closewindow();
  759. }
  760.  
  761. AGLOBAL void saveaminet(ABOOL saveas)
  762. {   /*  Short:        <short>
  763.         Uploader:     <uploader>
  764.         Author:       <author>
  765.         Type:         <type>
  766.         Replaces:     <replaces>
  767.         Requires:     <requires>
  768.         Version:      <version>
  769.         Distribution: <distribution>
  770.         
  771.         <long description> */
  772.  
  773.     readaminetgadgets();
  774.  
  775.     strcpy(IOBuffer, "Short:        ");
  776.     strcat(IOBuffer, aminet.amishort);
  777.     strcat(IOBuffer, "\n");
  778.     if (aminet.uploader[0])
  779.     {    strcat(IOBuffer, "Uploader:     ");
  780.             strcat(IOBuffer, aminet.uploader);
  781.         strcat(IOBuffer, "\n");
  782.     }
  783.     if (aminet.author[0])
  784.     {   strcat(IOBuffer, "Author:       ");
  785.         strcat(IOBuffer, aminet.author);
  786.         strcat(IOBuffer, "\n");
  787.     }
  788.     // it's compulsory to select a type
  789.     strcat(IOBuffer, "Type:         ");
  790.     strcat(IOBuffer, aminet.type);
  791.     strcat(IOBuffer, "\n");
  792.     if (aminet.replaces[0])
  793.     {   strcat(IOBuffer, "Replaces:     ");
  794.         strcat(IOBuffer, aminet.replaces);
  795.         strcat(IOBuffer, "\n");
  796.     }
  797.     if (aminet.requires[0])
  798.     {   strcat(IOBuffer, "Requires:     ");
  799.         strcat(IOBuffer, aminet.requires);
  800.         strcat(IOBuffer, "\n");
  801.     }
  802.     if (aminet.version[0])
  803.     {   strcat(IOBuffer, "Version:      ");
  804.         strcat(IOBuffer, aminet.version);
  805.         strcat(IOBuffer, "\n");
  806.     }
  807.     if (aminet.distribution[0])
  808.     {   strcat(IOBuffer, "Distribution: ");
  809.         strcat(IOBuffer, aminet.distribution);
  810.         strcat(IOBuffer, "\n");
  811.     }
  812.     strcat(IOBuffer, "\n");
  813.     strcat(IOBuffer, aminet.textfield);
  814.  
  815.     if (!aminet.output[0] || saveas) // if we need a filename
  816.     {   if (saveasl("Save Aminet Readme", "#?.readme"))
  817.         {   strcpy(aminet.output, aslresult);
  818.             writeout(aminet.output);
  819.     }   }
  820.     writeout(aminet.output);
  821. }
  822.  
  823. AGLOBAL void aminet_loop(ULONG gid)
  824. {   ULONG code;
  825.  
  826.     switch(gid)
  827.     {
  828.     case GID_2_LB1:
  829.         /* code is the position within the list, starting from 0. */
  830.         if (!(GetAttr
  831.         (   LISTBROWSER_Selected, aminet_gadgets[GID_2_LB1], (ULONG *) &code
  832.         )))
  833.         {   rq("Unsupported inquiry!"); // should never happen
  834.         }
  835.         aminet.maintype = code;
  836.         aminet.subtype  = 0;
  837.         updatesubtype();
  838.     break;
  839.     case GID_2_LB2:
  840.         /* code is the position within the list, starting from 0. */
  841.         if (!(GetAttr
  842.         (   LISTBROWSER_Selected, aminet_gadgets[GID_2_LB2], (ULONG *) &code
  843.         )))
  844.         {   rq("Unsupported inquiry!"); // should never happen
  845.         }
  846.         aminet.subtype = code;
  847.     break;
  848.     default:
  849.     break;
  850. }   }
  851.  
  852. AGLOBAL void newaminet(ABOOL display)
  853. {   aminet.amishort[0]     =
  854.     aminet.uploader[0]     =
  855.     aminet.author[0]       =
  856.     aminet.requires[0]     =
  857.     aminet.distribution[0] =
  858.     aminet.type[0]         =
  859.     aminet.replaces[0]     =
  860.     aminet.output[0]       =
  861.     aminet.textfield[0]    =
  862.     aminet.maintype        =
  863.     aminet.subtype         = 0;
  864.     strcpy(aminet.version, "1.0");
  865.  
  866.     if (display)
  867.         updateaminetgadgets();
  868. }
  869.  
  870. AGLOBAL void openaminet(void)
  871. {   if (asl("#?.readme"))
  872.     {   loadaminet();
  873.         updateaminetgadgets();
  874. }   }
  875.  
  876. AGLOBAL void loadaminet(void)
  877. {   ABOOL done = FALSE;
  878.     ULONG i, j, slashpos = 0;
  879.     TEXT  tempstring[13];
  880.  
  881.     if (readin(aslresult))
  882.     {   strcpy(aminet.output, aslresult);
  883.         offset = 0;
  884.  
  885.         // Clear all fields.
  886.         aminet.amishort[0]     =
  887.         aminet.uploader[0]     =
  888.         aminet.author[0]       =
  889.         aminet.requires[0]     =
  890.         aminet.distribution[0] =
  891.         aminet.type[0]         =
  892.         aminet.replaces[0]     =
  893.         aminet.output[0]       =
  894.         aminet.textfield[0]    =
  895.         aminet.maintype        =
  896.         aminet.subtype         =
  897.         aminet.version[0]      = 0;
  898.  
  899.         do
  900.         {   parse("\n");
  901.             if (string[0] == 0 || (string[0] == CR && string[1] == 0)) // CR support is for IBM-PC compatibility
  902.             {   done = TRUE;
  903.                 parsetoend();
  904.                 strcpy(aminet.textfield, string);
  905.             } elif (!strncmp(string, "Short:",         6))
  906.             {   for (i =  6; i < strlen(string); i++)
  907.                 {   if (string[i] != ' ')
  908.                     {   strcpy(aminet.amishort,     &string[i]);
  909.                         break;
  910.             }   }   }
  911.             elif (!strncmp(string, "Uploader:",      9))
  912.             {   for (i =  9; i < strlen(string); i++)
  913.                 {   if (string[i] != ' ')
  914.                     {   strcpy(aminet.uploader,     &string[i]);
  915.                         break;
  916.             }   }   }
  917.             elif (!strncmp(string, "Author:",        7))
  918.             {   for (i =  7; i < strlen(string); i++)
  919.                 {   if (string[i] != ' ')
  920.                     {   strcpy(aminet.author,       &string[i]);
  921.                         break;
  922.             }   }   }
  923.             elif (!strncmp(string, "Type:",          5))
  924.             {   for (i =  5; i < strlen(string); i++)
  925.                 {   if (string[i] != ' ')
  926.                     {   // OK, we are now at the start of useful data
  927.                         strcpy(aminet.type, &string[i]);
  928.                         while (aminet.type[slashpos] != '/')
  929.                         {   slashpos++;
  930.                         }
  931.                         // slashpos is now offset of '/'
  932.                         strncpy(tempstring, aminet.type, slashpos);                        tempstring[slashpos] = 0;
  933.                         for (j = 0; j <= MAINTYPES; j++)
  934.                         {   if (!strcmp(tempstring, category[j].name))
  935.                             {   aminet.maintype = j; // set up aminet.maintype
  936.                                 break;
  937.                         }   }
  938.                         slashpos++; // move past '/'
  939.                         for (j = offsets[aminet.maintype].start; j <= offsets[aminet.maintype].end; j++)
  940.                         {   if (!strcmp(&aminet.type[slashpos], category[j].name))
  941.                             {   aminet.subtype = j - offsets[aminet.maintype].start;
  942.                                 break;
  943.                         }   }
  944.                         break;
  945.             }   }   }
  946.             elif (!strncmp(string, "Replaces:",      9))
  947.             {   for (i =  9; i < strlen(string); i++)
  948.                 {   if (string[i] != ' ')
  949.                     {   strcpy(aminet.replaces,     &string[i]);
  950.                         break;
  951.             }   }   }
  952.             elif (!strncmp(string, "Requires:",      9))
  953.             {   for (i =  9; i < strlen(string); i++)
  954.                 {   if (string[i] != ' ')
  955.                     {   strcpy(aminet.requires,     &string[i]);
  956.                         break;
  957.             }   }   }
  958.             elif (!strncmp(string, "Version:",       8))
  959.             {   for (i =  8; i < strlen(string); i++)
  960.                 {   if (string[i] != ' ')
  961.                     {   strcpy(aminet.version,      &string[i]);
  962.                         break;
  963.             }   }   }
  964.             elif (!strncmp(string, "Distribution:", 13))
  965.             {   for (i = 13; i < strlen(string); i++)
  966.                 {   if (string[i] != ' ')
  967.                     {   strcpy(aminet.distribution, &string[i]);
  968.                         break;
  969.         }   }   }   }
  970.         while (!done);
  971. }   }
  972.  
  973. MODULE void updateaminetgadgets(void)
  974. {   SetGadgetAttrs
  975.     (   aminet_gadgets[GID_2_ST1], MainWindowPtr, NULL,
  976.         GTST_String, aminet.amishort,
  977.         TAG_END
  978.     );
  979.     SetGadgetAttrs
  980.     (   aminet_gadgets[GID_2_ST2], MainWindowPtr, NULL,
  981.         GTST_String, aminet.uploader,
  982.         TAG_END
  983.     );
  984.     SetGadgetAttrs
  985.     (   aminet_gadgets[GID_2_ST3], MainWindowPtr, NULL,
  986.         GTST_String, aminet.author,
  987.         TAG_END
  988.     );
  989.     SetGadgetAttrs
  990.     (   aminet_gadgets[GID_2_ST4], MainWindowPtr, NULL,
  991.         GTST_String, aminet.version,
  992.         TAG_END
  993.     );
  994.     SetGadgetAttrs
  995.     (   aminet_gadgets[GID_2_ST5], MainWindowPtr, NULL,
  996.         GTST_String, aminet.replaces,
  997.         TAG_END
  998.     );
  999.     SetGadgetAttrs
  1000.     (   aminet_gadgets[GID_2_ST6], MainWindowPtr, NULL,
  1001.         GTST_String, aminet.requires,
  1002.         TAG_END
  1003.     );
  1004.     SetGadgetAttrs
  1005.     (   aminet_gadgets[GID_2_ST7], MainWindowPtr, NULL,
  1006.         GTST_String, aminet.distribution,
  1007.         TAG_END
  1008.     );
  1009.     SetGadgetAttrs // `Type'
  1010.     (   aminet_gadgets[GID_2_LB1],
  1011.         MainWindowPtr, NULL,
  1012.         LISTBROWSER_Selected, aminet.maintype,
  1013.         TAG_END
  1014.     );
  1015.  
  1016.     updatesubtype();
  1017.  
  1018.     SetGadgetAttrs
  1019.     (   aminet_gadgets[GID_2_TE1], MainWindowPtr, NULL,
  1020.         GA_TEXTEDITOR_Contents, aminet.textfield,
  1021.         TAG_DONE
  1022.     );
  1023.     // It would be polite to scroll the listviews so that the selected
  1024.     // entries are visible.
  1025. }
  1026. AGLOBAL void readaminetgadgets(void)
  1027. {   STRPTR stringptr;
  1028.  
  1029.     if (!(GetAttr
  1030.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST1], (ULONG *) &stringptr
  1031.     )))
  1032.     {   rq("Unsupported inquiry!"); // should never happen
  1033.     }
  1034.     strcpy(aminet.amishort, stringptr);
  1035.  
  1036.     if (!(GetAttr
  1037.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST2], (ULONG *) &stringptr
  1038.     )))
  1039.     {   rq("Unsupported inquiry!"); // should never happen
  1040.     }
  1041.     strcpy(aminet.uploader, stringptr);
  1042.  
  1043.     if (!(GetAttr
  1044.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST3], (ULONG *) &stringptr
  1045.     )))
  1046.     {   rq("Unsupported inquiry!"); // should never happen
  1047.     }
  1048.     strcpy(aminet.author, stringptr);
  1049.  
  1050.     if (!(GetAttr
  1051.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST4], (ULONG *) &stringptr
  1052.     )))
  1053.     {   rq("Unsupported inquiry!"); // should never happen
  1054.     }
  1055.     strcpy(aminet.replaces, stringptr);
  1056.  
  1057.     if (!(GetAttr
  1058.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST5], (ULONG *) &stringptr
  1059.     )))
  1060.     {   rq("Unsupported inquiry!"); // should never happen
  1061.     }
  1062.     strcpy(aminet.requires, stringptr);
  1063.  
  1064.     if (!(GetAttr
  1065.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST6], (ULONG *) &stringptr
  1066.     )))
  1067.     {   rq("Unsupported inquiry!"); // should never happen
  1068.     }
  1069.     strcpy(aminet.version, stringptr);
  1070.  
  1071.     if (!(GetAttr
  1072.     (   STRINGA_TextVal, aminet_gadgets[GID_2_ST7], (ULONG *) &stringptr
  1073.     )))
  1074.     {   rq("Unsupported inquiry!"); // should never happen
  1075.     }
  1076.     strcpy(aminet.distribution, stringptr);
  1077.  
  1078.     strcpy(aminet.type, category[aminet.maintype].name);
  1079.     strcat(aminet.type, "/");
  1080.     strcat(aminet.type, category[offsets[aminet.maintype].start + aminet.subtype].name);
  1081.  
  1082.     stringptr = (STRPTR) DoGadgetMethod
  1083.     (   aminet_gadgets[GID_2_TE1], MainWindowPtr, NULL,
  1084.         GM_TEXTEDITOR_ExportText, NULL
  1085.     );
  1086.     strcpy(aminet.textfield, stringptr); // long description
  1087.     FreeVec((APTR) stringptr);
  1088.     // textBuffer = NULL;
  1089. }
  1090.  
  1091. AGLOBAL void aminet_init(void)
  1092. {   ULONG        i, j, length;
  1093.     struct Node* ListBrowserNodePtr;
  1094.  
  1095.     NewList(&SubTypeList);
  1096.  
  1097.     NewList(&MainTypeList);
  1098.     for (i = 0; i <= MAINTYPES; i++)
  1099.     {   strcpy(string, category[i].name);
  1100.         length = 5 - strlen(category[i].name);
  1101.         for (j = 1; j <= length; j++)
  1102.             strcat(string, " ");
  1103.         strcat(string, category[i].desc);
  1104.  
  1105.         if (!(ListBrowserNodePtr = AllocListBrowserNode
  1106.         (    1,              // columns,
  1107.              LBNA_Column,    0,
  1108.              LBNCA_CopyText, TRUE,
  1109.              LBNCA_Text,     string,
  1110.              TAG_END
  1111.         )))
  1112.         {   rq("Can't create ReAction listbrowser.gadget node(s)!");
  1113.         }
  1114.         AddTail(&MainTypeList, ListBrowserNodePtr); // AddTail() has no return code
  1115.         MainTypeNodes = TRUE;
  1116. }   }
  1117.  
  1118. AGLOBAL void aminet_die(void)
  1119. {   if (SubTypeNodes)
  1120.     {   clearreactionlist(&SubTypeList);
  1121.         SubTypeNodes = FALSE;
  1122.     }
  1123.     if (MainTypeNodes)
  1124.     {   clearreactionlist(&MainTypeList);
  1125.         MainTypeNodes = FALSE;
  1126. }   }
  1127.  
  1128. MODULE void updatesubtype(void)
  1129. {   ULONG        i, j, temp;
  1130.     struct Node* ListBrowserNodePtr;
  1131.      
  1132.     SetGadgetAttrs // `Subtype'
  1133.     (   aminet_gadgets[GID_2_LB2],
  1134.         MainWindowPtr, NULL,
  1135.         LISTBROWSER_Labels, NULL, // detach it
  1136.         TAG_END
  1137.     );
  1138.  
  1139.     if (SubTypeNodes)
  1140.     {   clearreactionlist(&SubTypeList);
  1141.     }
  1142.  
  1143.     SubTypeNodes = TRUE;
  1144.     for
  1145.     (   i = offsets[aminet.maintype].start;
  1146.         i <= offsets[aminet.maintype].end;
  1147.         i++
  1148.     )
  1149.     {   strcpy(string, category[i].name);
  1150.         temp = 6 - strlen(category[i].name);
  1151.         for (j = 1; j <= temp; j++)
  1152.             strcat(string, " ");
  1153.         strcat(string, category[i].desc);
  1154.  
  1155.         if (!(ListBrowserNodePtr = AllocListBrowserNode
  1156.         (    1,                   // columns,
  1157.              LBNCA_CopyText,      TRUE,
  1158.              LBNCA_Text,          string,
  1159.              TAG_END
  1160.         )))
  1161.         {   rq("Can't create ReAction listbrowser.gadget node(s)!");
  1162.         }
  1163.         AddTail(&SubTypeList, ListBrowserNodePtr); // AddTail() has no return code
  1164.     }
  1165.  
  1166.     SetGadgetAttrs // `Subtype'
  1167.     (   aminet_gadgets[GID_2_LB2],
  1168.         MainWindowPtr, NULL,
  1169.         LISTBROWSER_Labels, &SubTypeList,
  1170.         LISTBROWSER_Selected, aminet.subtype,
  1171.         TAG_END
  1172.     );
  1173. }
  1174.  
  1175. AGLOBAL ULONG Hook2Func(struct Hook *h, VOID *o, VOID *msg)
  1176. {   /* "When the hook is called, the data argument points to the 
  1177.     window object and message argument to the IntuiMessage." */
  1178.  
  1179.     UWORD code, qual;
  1180.     ULONG scroll = 0;
  1181.  
  1182.     geta4(); // wait till here before doing anything
  1183.  
  1184.     code = ((struct IntuiMessage *) msg)->Code;
  1185.     qual = ((struct IntuiMessage *) msg)->Qualifier;
  1186.  
  1187.     switch(code)
  1188.     {
  1189.     case SCAN_HELP:
  1190.         helpabout();
  1191.     break;
  1192.     case SCAN_ESCAPE:
  1193.         if ((qual & IEQUALIFIER_LSHIFT) || (qual & IEQUALIFIER_RSHIFT))
  1194.         {   cleanexit(EXIT_SUCCESS);
  1195.         } else page = 0;
  1196.     break;
  1197.     case SCAN_UP:
  1198.         if (qual & IEQUALIFIER_CONTROL)
  1199.         {   scroll = LBP_TOP;
  1200.         } elif (qual & IEQUALIFIER_LSHIFT || qual & IEQUALIFIER_RSHIFT)
  1201.         {   scroll = LBP_PAGEUP;
  1202.         } else scroll = LBP_LINEUP;
  1203.     break;
  1204.     case SCAN_DOWN:
  1205.         if (qual & IEQUALIFIER_CONTROL)
  1206.         {   scroll = LBP_BOTTOM;
  1207.         } elif (qual & IEQUALIFIER_LSHIFT || qual & IEQUALIFIER_RSHIFT)
  1208.         {   scroll = LBP_PAGEDOWN;
  1209.         } else scroll = LBP_LINEDOWN;
  1210.     break;
  1211.     case SCAN_S:
  1212.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST1]);
  1213.     break;
  1214.     case SCAN_U:
  1215.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST2]);
  1216.     break;
  1217.     case SCAN_A:
  1218.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST3]);
  1219.     break;
  1220.     case SCAN_R:
  1221.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST4]);
  1222.     break;
  1223.     case SCAN_E:
  1224.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST5]);
  1225.     break;
  1226.     case SCAN_V:
  1227.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST6]);
  1228.     break;
  1229.     case SCAN_D:
  1230.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_ST7]);
  1231.     break;
  1232.     case SCAN_L:
  1233.         ActivateLayoutGadget(aminet_gadgets[GID_2_LY1], MainWindowPtr, NULL, (Object) aminet_gadgets[GID_2_TE1]);
  1234.     break;
  1235.     default:
  1236.     break;
  1237.     }
  1238.  
  1239.     if (code == SCAN_UP || code == SCAN_DOWN)
  1240.     {   SetGadgetAttrs
  1241.         (   aminet_gadgets[GID_2_LB2],    // pointer to gadget
  1242.             MainWindowPtr,                // pointer to window (not window object!)
  1243.             NULL,                         // pointer to requester
  1244.             LISTBROWSER_Position, scroll, // tags
  1245.             TAG_DONE                      // done
  1246.         );
  1247.     }
  1248.  
  1249.     return(1);
  1250. }
  1251.  
  1252.